<template>
  <div>
    <input type="text" 
    ref="element"
    placeholder="组件加载时,自动聚焦到我">
    <hr>
  </div>
</template>

<script setup>
import { ref,onMounted } from 'vue'
const element = ref(null)
onMounted(() => {
  element.value.focus();
})
</script>

<style scoped>

</style>